package com.max.utils;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Component
public class JwtUtils {

    private final String secretPrivate="xxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaa";
    private final Long expireTime=86400L;//24*60*60

    public String createJWTToken(Map<String,Object> claims,String subject){
        Long nowMillis=System.currentTimeMillis();
        String token= Jwts.builder()
                .addClaims(claims)
                .setSubject(subject)
                .setIssuedAt(new Date(nowMillis))
                .setExpiration(new Date((nowMillis+expireTime*1000)))
                .signWith(SignatureAlgorithm.ES512,secretPrivate)
                .compact();

        return "";
    }
}



